#ifndef GPSMETADATADB_H_
#define GPSMETADATADB_H_

#pragma once

#include <db_cxx.h>
#include <string>

class CGPSMetadataDB
{
public:
	CGPSMetadataDB(std::string path, std::string name, int accflag);
	~CGPSMetadataDB() { CloseDB(); }

	inline Db& GetDB() { return m_db; }

	inline Db& Get_SecondDB_RecvIndex() { return m_recv_index; }

	void WriteDB(time_t time, const char * pdata, int len);
	int ReadDB(time_t time, void * pbuf, int bufsize);
	int ReadNrecvtimeIndexDB(time_t time, void * pbuf, int bufsize, time_t *pkeyval);

	void ReadDBUseCursor();
	void ReadReactimeIndexDBUseCursor();

private:
	Db	m_db;
	Db	m_recv_index;
	std::string m_dbfile;
	int accessmethod;

	CGPSMetadataDB() : m_db(NULL, 0), m_recv_index(NULL, 0) { }
	void CloseDB();
};

#endif